package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.KnowledgeDao;
import com.itheima.domain.KnowledgeUser;
import com.itheima.domain.PageResult;
import com.itheima.service.KnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class KnowledgeServiceImpl implements KnowledgeService {
    @Autowired
  private KnowledgeDao knowledgeDao;//注解注入

    //评估与建议************************************************************
    @Override
    public PageResult pageQueryAdvice(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<KnowledgeUser> page = knowledgeDao.selectByConditionAdvice(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public KnowledgeUser findByIdAdvice(Integer LoreID){//根据id查
        return knowledgeDao.findByIdAdvice(LoreID);
    }

    @Override
    public void addAdvice(KnowledgeUser knowledgeUser) {//增加数据
        knowledgeDao.addAdvice(knowledgeUser);
    }

    @Override
    public void updateAdvice(KnowledgeUser knowledgeUser) {
        knowledgeDao.updateAdvice(knowledgeUser);//修改数据
    }

    @Override
    public void deleteAdvice(Integer id) {//删
        knowledgeDao.deleteAdvice(id);
        System.out.println(id);
    }
    //************************************************************



    //运动项目库+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    @Override
    public PageResult pageQuerySport(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<KnowledgeUser> page = knowledgeDao.selectByConditionSport(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public KnowledgeUser findByIdSport(Integer Number){//根据id查
        return knowledgeDao.findByIdSport(Number);
    }

    @Override
    public void addSport(KnowledgeUser knowledgeUser) {//增加数据
        knowledgeDao.addSport(knowledgeUser);
    }

    @Override
    public void updateSport(KnowledgeUser knowledgeUser) {//修改数据
        knowledgeDao.updateSport(knowledgeUser);
    }

    @Override
    public void deleteSport(Integer id) {//删
        knowledgeDao.deleteSport(id);
    }
    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //膳食库-------------------------------------------------------
    //膳食库分页查询
    @Override
    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<KnowledgeUser> page = knowledgeDao.selectByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }
    @Override
    public KnowledgeUser findById(Integer FoodID){//根据id查
        return knowledgeDao.findById(FoodID);
    }

    @Override
    public void add(KnowledgeUser knowledgeUser) {//增加数据
        knowledgeDao.add(knowledgeUser);
    }

    @Override
    public void update(KnowledgeUser knowledgeUser) {//修改数据
        knowledgeDao.update(knowledgeUser);
    }

    @Override
    public void delete(Integer id) {//根据id删除数据
        knowledgeDao.delete(id);
    }


    //项目库-------------------------------------------------------
    //项目库分页查询
    @Override
    public PageResult pageQueryItem(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<KnowledgeUser> page = knowledgeDao.selectByConditionItem(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }
    @Override
    public KnowledgeUser findByIdItem(Integer ItemID){//根据id查
        return knowledgeDao.findByIdItem(ItemID);
    }

    @Override
    public void addItem(KnowledgeUser knowledgeUser) {//增加数据
        knowledgeDao.addItem(knowledgeUser);
    }

    @Override
    public void updateItem(KnowledgeUser knowledgeUser) {//修改数据
        knowledgeDao.updateItem(knowledgeUser);
    }

    @Override
    public void deleteItem(Integer ItemID) {//根据id删除数据
        knowledgeDao.deleteItem(ItemID);
    }
}
